Version 3.0 User's Guide |
|
Comparison Operators |
Previous |
Next Contents |
All NetCloak SHOW and HIDE commands let you specify one of thirteen comparison operators, which let you specify exactly how to compare a NetCloak variable to the parameters listed in the command.
A comparison operator causes NetCloak to perform a logical test, which has either a true or false result. If the result is true, then a SHOW command causes text following it to be shown; and a HIDE command causes the text to be hidden. If the result of the test is false, then the command has no effect on the page.
The comparison operator may be omitted from the command. If it is, a default comparison operator is used which is specific to each command. The default comparison operator for each command is listed in the command's description later in this User's Guide. In all cases, the default comparison operator permits backward-compatibility with versions of NetCloak prior to 3.0.
Comparison operators fall into one of two categories: text comparisons and numeric comparisons. Be sure you know which kind of operator you are using, or you will get unexpected results in your web pages.
Text comparison operators treat the variable and the command parameters as sequences of alphabetic characters. All text comparisons are case-insensitive, which means that the capitalization of the characters is ignored. Therefore, "bob" and "BoB" are considered an exact match. The text operators, and the tests they perform, are listed below.
For the examples shown below, assume the existence of a NetCloak global variable named "Platform" with the value "Macintosh".
<HIDE_GLOBAL Platform CONTAINS "mac"> <HIDE_GLOBAL Platform CONTAINS "into"> <HIDE_GLOBAL Platform CONTAINS "mAcInTosh">
<HIDE_GLOBAL Platform IS "mac"> <HIDE_GLOBAL Platform IS "into"> <HIDE_GLOBAL Platform IS "mAcInTosh">
<HIDE_GLOBAL Platform IN "Welcome to Macintosh.">
<HIDE_GLOBAL Platform BEGINS "mac"> <HIDE_GLOBAL Platform BEGINS "into"> <HIDE_GLOBAL Platform BEGINS "Macintosh ">
The third example fails the test because the text parameter contains extra space characters.
<HIDE_GLOBAL Platform ENDS "tosh"> <HIDE_GLOBAL Platform ENDS "into"> <HIDE_GLOBAL Platform ENDS " Macintosh">
The third example fails the test because the text parameter contains extra space characters.
Using ASCII values, whitespace characters sort before digit characters, and digit characters sort before all alphabetic characters. Also, if all characters in a short word match a longer word, the shorter word sorts before the longer word.
Note: the BEFORE operator is not a date/time comparison operator. You usually do not want to use this operator in date/time commands.
Of the following examples, only the second one will cause text to be hidden using our "Platform" global variable:
<HIDE_GLOBAL Platform BEFORE "mac"> <HIDE_GLOBAL Platform BEFORE "windows"> <HIDE_GLOBAL Platform BEFORE "123xyz">
Using ASCII values, whitespace characters sort before digit characters, and digit characters sort before all alphabetic characters. Also, if all characters in a short word match a longer word, the shorter word sorts before the longer word.
Note: the AFTER operator is not a date/time comparison operator. You usually do not want to use this operator in date/time commands.
Of the following examples, only the third one will cause text to be hidden using our "Platform" global variable:
<HIDE_GLOBAL Platform AFTER "Macintosh"> <HIDE_GLOBAL Platform AFTER "windows"> <HIDE_GLOBAL Platform AFTER "123xyz">
<HIDE_GLOBAL Platform EXISTS> <SET_GLOBAL Platform = "Macintosh"> <SHOW>
Numeric comparison operators treat the variable and the command parameters as numbers, converting text parameters to numbers as necessary. Numeric values may only contain these characters:
A variable that contains other characters will be treated as text by NetCloak, and will be converted to the number zero for a numeric comparison.
In date and time commands, the date and time parameters are converted to a single number in seconds. This allows comparisons and other operations in date commands to work just like those for plain numbers.
The numeric operators, and the tests they perform, are listed below. For the examples below, assume the existence of a counter named "Orders" with a value of 250.
<HIDE_COUNT Orders == 50 150 250 350>
<HIDE_COUNT Orders LT 50> <HIDE_COUNT Orders LT 250> <HIDE_COUNT Orders LT 500>
<HIDE_COUNT Orders LT= 50> <HIDE_COUNT Orders LT= 250> <HIDE_COUNT Orders LT= 500>
<HIDE_COUNT Orders GT 50> <HIDE_COUNT Orders GT 250> <HIDE_COUNT Orders GT 500>
<HIDE_COUNT Orders GT= 50> <HIDE_COUNT Orders GT= 250> <HIDE_COUNT Orders GT= 500>
Comparison operators in NetCloak SHOW and HIDE commands can be negated by inserting a "#" character in the command immediately before or after the comparison operator. This character reverses the result of the comparison, so that the HIDE or SHOW occurs if the test is NOT true. Some examples will make this clear.
<HIDE_CLIENT #CONTAINS "AOL"> Welcome America Online users! <SHOW>
This command shows a special message only to America Online users by hiding the text if the client name does not contain the text "AOL". Read the command like this: "Hide if the client does NOT contain AOL".
You can put the # character either at the end of the show or hide command, or either before or after the comparison operator. All of the commands below are equivalent:
<HIDE_CLIENT# CONTAINS "Mozilla"> <HIDE_CLIENT #CONTAINS "Mozilla"> <HIDE_CLIENT CONTAINS# "Mozilla">
Here is one more example:
<HIDE_VARIABLE OSPreference IS# "MacOS"> You have selected MacOS as your preferred operating system. Congratulations! <SHOW>
This code hides the congratulatory message from users who have chosen some other OS. (The command reads "Hide if the form variable "OSPreference" is not "MacOS".)
The negation operator can also be used with the default comparison by adding it directly to a HIDE or SHOW command. For example:
<HIDE><SHOW_DAY# SAT SUN>
Copyright © 1996-1999 Maxum Development Corporation http://www.maxum.com/ |
Previous |
Next Contents |